package leetcode.L1000;

import java.util.LinkedList;

public class EX705 {


    final int N = 10007;
    LinkedList<Integer>[] h;
    /** Initialize your data structure here. */
    public EX705() {
        h = new LinkedList[N];
    }

    public void add(int key) {
        int t = key%N;
        if(h[t]==null){
            h[t] = new LinkedList<Integer>();
        }
        if(find(h[t],key)==-1){
            h[t].add(key);
        }
    }

    public void remove(int key) {
        int t = key%N;

        if(h[t]!=null) {
            int k = find(h[t], key);
            if (k != -1) {
                h[t].remove(k);
            }
        }
    }

    /** Returns true if this set contains the specified element */
    public boolean contains(int key) {
        int t = key%N;
        if(h[t]!=null) {
            int k = find(h[t], key);
            if (k != -1) {
                return true;
            }
        }
        return false;

    }
    public int find(LinkedList<Integer> list,int key){
        for (int i = 0; i < list.size(); i++) {
            if(list.get(i)==key){
                return i;
            }
        }
        return -1;
    }
}
